gridview: Work around unexpected focus changes
authorMatthias Clasen <mclasen@redhat.com>
Thu, 6 Aug 2020 18:35:19 +0000 (14:35 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 6 Aug 2020 18:35:19 +0000 (14:35 -0400)
As things currently stand, we get events for focus changes
before the widget is allocated, and try to scroll in response.
Therefore, leaving n_columns at 0 until size-allocate leads
to plenty of division-by-zero. Just set it to 1 initially
to avoid that. This is a workaround for #3025.

gtk/gtkgridview.c

index ecbb741f8fa2a300f7e5bba86dc2d02c7d49328c..a945683b0390e9fa7fccf5ca8754d5fb0c38b675 100644 (file)
@@ -1167,6 +1167,7 @@ gtk_grid_view_init (GtkGridView *self)
 
   self->min_columns = 1;
   self->max_columns = DEFAULT_MAX_COLUMNS;
+  self->n_columns = 1;
 
   gtk_list_base_set_anchor_max_widgets (GTK_LIST_BASE (self),
                                         self->max_columns * GTK_GRID_VIEW_MAX_VISIBLE_ROWS,